import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.Console;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.util.regex.Pattern;
import java.util.regex.Matcher;

public class program
{
	public static void main(String[] args) throws IOException
	{
		BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));
		BufferedWriter stdout = new BufferedWriter(new OutputStreamWriter(System.out));
		
		while (true)
		{
			Pattern pattern = Pattern.compile(stdin.readLine());
			
			Matcher matcher = pattern.matcher(stdin.readLine());
			
			boolean found = false;
			
			while (matcher.find())
			{
				
				System.out.println(matcher.group() + ' ');
				found = true;
			}
			
			if (!found)
			{
				System.out.println("No matcher found!");
			}
		}
		/*常见regex
		 * [bcr]at
		 * [^bcr]at
		 * [a-c]at
		 * X?
		 * X??
		 * X?+
		 * X{n}
		 * X{n}?
		 * X{n}?+
		 * ^ ling begining
		 * $ end of line
		 * \b word boundary
		 * Pattern.CASE_INSENSTIVE
		 * \d\s\w(注意， 在String中定义的时候， 需要加上转义符
		 */
	}
}
			
			